//
//  TabBarController.m
//  WE
//
//  Created by 然然 on 15/11/17.
//  Copyright © 2015年 然然. All rights reserved.
//

#import "TabBarController.h"
#import "UserViewController.h"
#import "WeViewController.h"
#import "ChatViewController.h"
#import "CommunityViewController.h"
#import "NotificationViewController.h"
#import "DiscoverViewController.h"


@interface TabBarController ()

@end

@implementation TabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    
    
    
    WeViewController *weVC = [[WeViewController alloc] initWithNibName:@"WeViewController" bundle:[NSBundle mainBundle]];
    [self addChildVC:weVC title:@"我们" imageNmae:nil selectedImageName:nil tag:0];
    UINavigationController *weNC = [[UINavigationController alloc]initWithRootViewController:weVC];
    
    CommunityViewController *communityVC = [[CommunityViewController alloc] initWithNibName:@"CommunityViewController" bundle:[NSBundle mainBundle]];
    [self addChildVC:communityVC title:@"社区" imageNmae:nil selectedImageName:nil tag:0];
    UINavigationController *communityNC = [[UINavigationController alloc]initWithRootViewController:communityVC];
    
    ChatViewController *chatVC = [[ChatViewController alloc] initWithNibName:@"ChatViewController" bundle:[NSBundle mainBundle]];
    [self addChildVC:communityVC title:@"聊天" imageNmae:nil selectedImageName:nil tag:0];
    UINavigationController *chatNC = [[UINavigationController alloc]initWithRootViewController:chatVC];
    
    DiscoverViewController *discoverVC = [[DiscoverViewController alloc] initWithNibName:@"DiscoverViewController" bundle:[NSBundle mainBundle]];
    [self addChildVC:discoverVC title:@"发现" imageNmae:nil selectedImageName:nil tag:0];
    UINavigationController *discoverNC = [[UINavigationController alloc]initWithRootViewController:discoverVC];
    
    NotificationViewController *notificationVC = [[NotificationViewController alloc] initWithNibName:@"NotificationViewController" bundle:[NSBundle mainBundle]];
    [self addChildVC:notificationVC title:@"通知" imageNmae:nil selectedImageName:nil tag:0];
    UINavigationController *notificationNC = [[UINavigationController alloc]initWithRootViewController:notificationVC];
    
    
  self.viewControllers = @[weNC, communityNC, chatNC, discoverNC, notificationNC];
    

    
    
    
    
    // Do any additional setup after loading the view.
}



-(void)addChildVC:(UIViewController *)childVC title:(NSString *)title imageNmae:(NSString *)imageNmae selectedImageName:(NSString *)selectedImageName tag:(NSInteger)tag
{
    childVC.title=  title;
    //    childVC.tabBarItem = [[UITabBarItem alloc] initWithTitle:title image:[UIImage imageNamed:imageNmae] tag:tag];
    childVC.tabBarItem.selectedImage = [[UIImage imageNamed:selectedImageName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
